package api

import (
	"github.com/fantomo/go-iching/utils/http"
	"github.com/gin-gonic/gin"
)

type DivinationController struct{}

func (ctrl *DivinationController) Get(c *gin.Context) {
	symbol := c.Query("symbol")

	if symbol == "" {
		http.ResponseHandle(c, http.Response{Code: http.REQUEST_PARAM_ERROR, Msg: "请求参数错误!"})
		return
	}

	divinationService := DivinationService{Symbol: symbol}
	servRes := divinationService.Get()
	msg := servRes.Msg
	if servRes.Ok == false {
		msg = "卜算失败,请静下心来重新摇卦!"
	}
	http.ResponseHandle(c, http.Response{Code: servRes.Code, Data: servRes.Content, Msg: msg, Ok: servRes.Ok})
}


func (ctrl *DivinationController) GetAll(c *gin.Context) {
	divinationService := DivinationService{}
	servRes := divinationService.GetAll()
	msg := servRes.Msg
	if servRes.Ok == false {
		msg = "卜算失败,请静下心来重新摇卦!"
	}
	http.ResponseHandle(c, http.Response{Code: servRes.Code, Data: servRes.Content, Msg: msg, Ok: servRes.Ok})
}
